package com.hrbxlh.util;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * 返回结果枚举类
 *
 * @author cheer
 */
public enum ResultEnum {

    SUCCESS(200, "请求成功"),

    // 通用异常
    BAD_REQUEST(400, "参数不合法"),
    UNAUTHORIZED(401, "用户未登录或已超时"),
    FORBIDDEN(403, "用户没有执行该请求的权限"),
    NOT_FOUND(404, "内容不存在"),
    SERVER_ERROR(500, "服务器内部错误"),
    SYSTEM_BUSY(1000, "系统繁忙，请稍后再试"),
    LICENSE_EXPIRE(2000, "License过期"),

    // 删除处理异常
    DELETE_DEAL_EXCEPTION(501, "删除处理异常"),

    SESSION_TIMEOUT(1001001008,"会话已超时，请重新访问"),

    // 业务异常
    // 实验模块
    FILE_UPLOAD_ERROR(500106, "文件上传异常"),
    IMAGE_IS_ALLOCATED(500400, "镜像正在被使用，强制删除镜像会导致使用该镜像的容器、相关的镜像分配立即删除，请谨慎操作"),

    // 用户模块
    LOGIN_FAILED(100100, "登录失败"),
    USER_INFO_MATCH_FAILED(100101, "用户名或密码错误"),
    VERIFICATION_CODE_ERROR(100102, "验证码错误"),
    ACCOUNT_NOT_EXIST(100103, "账号不存在"),
    ACCOUNT_EXPIRED(100104, "账号已过期"),
    USER_EXIST(100105, "用户已存在"),

    // 课程
    COURSE_NOT_OWNER(100106, "当前课程不属于自己的课程"),

    // 导出excel
    EXCEL_OUTPUT_EXCEPTION(500600, "导出excel失败"),

    FILE_DOWNLOAD_ERROR(500700, "远程文件下载失败");

    private Integer code;

    private String message;

    ResultEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("code", code)
                .append("message", message)
                .toString();
    }
}
